home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 76623,2065@compuserve.com (Bobby Martin)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ newbie asks for help
- Date: 18 Mar 1996 16:28:29 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4ik2vd$euq@dub-news-svc-4.compuserve.com>
- References: <31488AC8.1557@cco.caltech.edu>
- Reply-To: 76623,2065@compuserve.com (Bobby Martin)
- NNTP-Posting-Host: ad51-239.compuserve.com
- X-Newsreader: IBM NewsReader/2 v1.03
-
- In <31488AC8.1557@cco.caltech.edu>, Xuhua Li <xuhua@cco.caltech.edu> writes:
- >The following C++ programs from Stephen Prata's book <<C++ Primer Plus>>
- >does not work properly compiled by Microsoft C++ 4.0 under Window 95.
- >Can anybody help me out there?
-
- <snip>
-
- Your problem in the first program (and possibly the second, I'm not sure...)
- is that cout is buffered, and the actual write from the buffer to the screen
- either happens whenever the buffer is full or the compiler feels like putting it
- in (I know there are some controlling criteria here but I'm unsure what they
- are), or when you explicitely say so using 'flush' or 'endl'.
-
- In short, to solve your problem end your cout's with 'endl' instead of \n
- like this:
-
- cout << "starting\a" << endl;
-
- instead of
-
- cout << "starting\a\n";
-
- Hope that helps
-
- Bobby Martin
-